<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 有一个从小到大排好序的数组。现输入一个数，要求按原来的规律将它插入数组中
    var arr = [];
    var arr1 = [];
    function plus(arr,n){
        for(i = 0;i < arr.length + 1; i++){
            if(arr[i] < n){ 
                arr1[i] = arr[i];
            }
            else if(arr[i - 1] < n && arr[i] >= n){
                arr1[i] = n;
            }
            else{
                arr1[i] = arr[i-1];
            }
        }
        return arr1
    }
    plus([15,45,60,75,100,105],80)
    console.log(plus([15,45,60,75,100,105],80))
</script>
</html>